using AutoMapper;
using Joy.Erp.BasicArchives.Core;

namespace Joy.Erp.BasicArchives.ItemMasters
{
    public class BomMasterAutoMapperProfile : Profile
    {
        public BomMasterAutoMapperProfile()
        {
            CreateMap<BomMaster, BomMasterDto>().MapExtraProperties().ReverseMap();
            CreateMap<BomMaster, BomMasterDocumentDto>().MapExtraProperties().ReverseMap();
            CreateMap<BomMaster, BomMasterCreateDto>().MapExtraProperties().ReverseMap();
            CreateMap<BomMaster, BomMasterUpdateDto>()
                .MapExtraProperties()
                .ForMember(dest => dest.Children, opt => opt.Ignore());
            CreateMap<BomMasterUpdateDto, BomMaster>()
                .MapExtraProperties()
                .ForMember(dest => dest.Id, opt => opt.Ignore())
                .ForMember(dest => dest.ItemMaster, opt => opt.Ignore())
                .ForMember(dest => dest.Unit, opt => opt.Ignore())
                .MapChildren<BomMasterUpdateDto, BomMaster, BomComponentCreateOrUpdateDto, BomComponent>();

            CreateMap<BomComponent, BomComponentDto>().MapExtraProperties().ReverseMap();
            CreateMap<BomComponent, BomComponentCreateOrUpdateDto>().MapExtraProperties().ReverseMap();
        }
    }
}